// Filename: router.js
define([  
  'backbone',  
  'views/person/viewPersons',
  'views/person/updatePerson',
  'views/person/savePerson',
  'views/person/deletePerson'
], function(Backbone, PersonListView, PersonEditView, PersonSaveView, PersonDeleteView){
	var Router = Backbone.Router.extend({
		routes: {
			'': 'home',
			'new': 'saveUser',
			'edit/:id' : 'editUser' ,
			'delete/:id' : 'deleteUser'
		}
	});

  var initialize = function(){
    var router = new Router();
		router.on('route:home', function(){
			var userList = new PersonListView();
			userList.render();
		});
		router.on('route:saveUser', function(){
			var saveUser = new PersonSaveView();
			saveUser.render();
		});
		router.on('route:editUser', function(id) {
			var editUser = new PersonEditView();
			editUser.render({id: id});
		});
		router.on('route:deleteUser', function(id) {
			var deleteUser = new PersonDeleteView();
			deleteUser.render({id: id});
		});
    Backbone.history.start();
  };
  return {
    initialize: initialize
  };
});